You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Extend hotfix label automation to cover issues - #4741
Extends the existing "Hotfix X.Y.Z" PR cherry-pick automation to also cover issues, so backport tracking issues are created and linked automatically instead of manually (as done for #4737/#4738).
create-backport-issue.sh + hotfix-label-issue.yml: labeling a parent issue Hotfix X.Y.Z creates a child backport issue milestoned to that version and links it as a native GitHub sub-issue. Includes duplicate detection (by milestone or title prefix) so a re-fired labeled event won't create a second backport issue.
sync-hotfix-label-to-pr.sh + sync-hotfix-label-to-pr.yml: when a PR's closing issue references include a Hotfix-labeled issue, that label is copied onto the PR, feeding it into the existing cherry-pick automation.
cherry-pick-to-release.sh (extended): looks up the milestone-matched backport issue via the original PR's closing references and appends Fixes #N to the auto-generated cherry-pick PR body (both the clean and conflict paths), so merging the backport PR automatically closes the backport issue.
Added issues: read permission to cherry-pick-hotfix.yml for the new lookup.
End-to-end flow: label an issue Hotfix 7.1.1 -> backport issue #N created and sub-issued -> PR opened closing the parent issue picks up the Hotfix 7.1.1 label -> merging that PR triggers the existing cherry-pick automation -> generated backport PR links Fixes #N.
Issues
Not tied to a specific bug fix; this generalizes the manual backport-issue pattern used for #4737 and #4738 into automation.
Testing
Added bats coverage for all new/changed behavior, run locally with bats-core:
cherry-pick-to-release.bats (19 tests, 4 new): backport-issue lookup and Fixes #N linking in both the clean and conflict PR-body paths; all 16 pre-existing tests still pass unmodified.
Also ran shellcheck against the new/modified scripts with no new findings.
Guidelines
Please review the contribution guidelines before submitting a pull request:
- create-backport-issue.sh + hotfix-label-issue.yml: labeling an issue
"Hotfix X.Y.Z" creates a child backport issue milestoned to that
version and links it as a native GitHub sub-issue.
- sync-hotfix-label-to-pr.sh + sync-hotfix-label-to-pr.yml: copies the
Hotfix label onto a PR when its closing issue references include a
Hotfix-labeled issue, feeding the existing cherry-pick automation.
- cherry-pick-to-release.sh: looks up the milestone-matched backport
issue via the PR's closing references and appends "Fixes #N" to the
generated cherry-pick PR body (both clean and conflict paths), so
merging it auto-closes the backport issue.
- Added bats tests for all new/changed behavior and updated the tests
README.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Live-testing lookup_backport_issue() against real GitHub issues/PRs
revealed that 'gh api --jq --arg v "$version" ...' silently fails
(gh's --jq flag takes a single query string; it isn't a passthrough
to the jq binary's own flags). The stderr redirect masked the failure,
so the function always returned no match.
Fix by escaping and interpolating the version directly into the jq
filter string instead of relying on --arg.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…error handling, exact label matching, workflow permissions
- cherry-pick-to-release.sh / sync-hotfix-label-to-pr.sh: filter
closingIssuesReferences by repository before extracting issue numbers, so a
cross-repo closing reference can't collide with a same-numbered local issue.
- create-backport-issue.sh: fail loudly instead of silently proceeding when
the sub-issues duplicate-guard lookup itself fails, to avoid creating a
duplicate backport issue on a rerun after a transient API error.
- sync-hotfix-label-to-pr.sh: require the exact "Hotfix X.Y.Z" grammar
when collecting labels from referenced issues, matching the validation used
elsewhere, instead of accepting any "Hotfix "-prefixed label.
- hotfix-label-issue.yml / sync-hotfix-label-to-pr.yml: add the missing
'contents: read' permission needed by actions/checkout.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Process all matching parent issues before returning
.github/scripts/cherry-pick-to-release.sh:202
Returning after the first match leaves other backport issues open when one PR closes multiple Hotfix-labeled parent issues for the same version. Accumulate one Fixes line per matching parent and finish the loop instead.
Fail on milestone API errors before using fallback
.github/scripts/create-backport-issue.sh:125
Because this API call is the left side of an if pipeline, an API failure is treated exactly like a missing milestone. The workflow then creates an unmilestoned issue despite the milestone potentially existing. Fetch the titles first so set -e stops on API failure, and only use the fallback after a successful lookup.
Recover orphaned issues after partial creation failure
.github/scripts/create-backport-issue.sh:154
Issue creation is committed before the child is linked. If either the child-ID lookup or sub-issue POST fails, rerunning checks only linked sub-issues, does not find this orphan, and creates another backport issue. Before creating, detect and relink an existing issue with this generated title/parent marker (or otherwise persist recovery state) so retries remain idempotent after partial failure.
…ck-then-create race
Duplicate detection is a check-then-create sequence with no atomic guard.
Two deliveries/re-runs for the same issue+label could both observe no
existing child and create duplicates. A job-level concurrency group keyed
by issue number and label serializes runs so a second run always re-checks
after the first has finished.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
A PR can close multiple Hotfix-labeled issues, but this returns after the first matching child, so only one generated backport issue gets a Fixes line and the others remain open after the cherry-pick PR merges. Accumulate every version-matched child instead of stopping at the first.
Use fixed-string matching for exact versions
.github/scripts/create-backport-issue.sh:137
This exact-version check is using a regular expression, so the dots in 7.1.1 match arbitrary characters; for example, milestone 7x1y1 is treated as a match and the subsequent create call then requests nonexistent milestone 7.1.1. Use fixed-string matching.
Recover orphaned backport issues on rerun
.github/scripts/create-backport-issue.sh:166
After this issue is created, a failure while resolving its ID or linking it leaves an orphan. On rerun, the duplicate guard only searches existing sub-issues, so it cannot find that orphan and creates another backport issue. Make the create/link sequence recoverable by discovering and linking a previously created matching child before creating a new one.
If an issue receives its Hotfix label after a closing PR is already open, none of these PR events is emitted. The backport child is created, but the PR never receives the label and can merge without triggering the cherry-pick workflow. Handle the issues:labeled path by finding and labeling existing closing PRs (or dispatching a reusable sync workflow), not only future PR events.
The trailing '|| true' covered the whole 'gh issue view | grep' pipeline, so
a real gh API/permission failure was indistinguishable from an issue simply
having no Hotfix labels, and the run would succeed without labeling the PR.
Capture 'gh issue view' separately and fail loudly on its error; only grep's
no-match exit status is now tolerated.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Prevent orphaned duplicate child issues after linking failures
.github/scripts/create-backport-issue.sh:180
Issue creation and sub-issue linking are separate writes. If this POST fails after creation, the child remains orphaned; a rerun checks only linked sub-issues and creates another child, defeating duplicate protection. Before creating, detect and reuse an existing matching issue that references this parent, or otherwise make the failed link recoverable on rerun.
Update reported test count from 10 to 11
.github/scripts/tests/README.md:125
This table reports 10 tests, but create-backport-issue.bats currently contains 11 @test cases. Update the count so the test inventory is accurate.
Document how hotfix-label-issue.yml, sync-hotfix-label-to-pr.yml, and
cherry-pick-hotfix.yml work together, with a Mermaid diagram of the
end-to-end flow from labeling an issue through to the linked
cherry-pick PR. Link the new doc from each workflow's header comment.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
lookup_backport_issue() returned as soon as it found a matching
sub-issue for the first closing issue reference, so a PR that closes
multiple Hotfix-labeled parent issues for the same release only linked
one backport issue and left the others open. Accumulate a Fixes line
for every closing issue that has a matching backport sub-issue instead
of stopping at the first match.
Also simplify the hotfix-label-automation.md diagram to show actions
and results rather than individual workflow/script names.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This changed block adds literal non-ASCII em dashes to source comments. Repository policy requires Unicode escapes for non-ASCII source characters (policy/coding-style.md:56-58); use ASCII punctuation in the added comments.
Replace non-ASCII comment punctuation with ASCII
.github/scripts/create-backport-issue.sh:27
This file introduces literal non-ASCII punctuation in comments, including this em dash. Repository policy requires Unicode escapes for non-ASCII source characters (policy/coding-style.md:56-58); use ASCII punctuation throughout this new script.
This issue also appears on line 176 of the same file.
Replace non-ASCII comment punctuation with ASCII
.github/scripts/sync-hotfix-label-to-pr.sh:66
This file introduces literal non-ASCII punctuation in comments, including this em dash. Repository policy requires Unicode escapes for non-ASCII source characters (policy/coding-style.md:56-58); use ASCII punctuation throughout this new script.
The new test file uses literal box-drawing characters and em dashes in comments. Repository policy requires Unicode escapes for non-ASCII source characters (policy/coding-style.md:56-58); replace these comment separators and punctuation with ASCII throughout the file.
The new test file uses literal box-drawing characters and em dashes in comments. Repository policy requires Unicode escapes for non-ASCII source characters (policy/coding-style.md:56-58); replace these comment separators and punctuation with ASCII throughout the file.
gh issue list --json author serializes bot logins with an app/ prefix (Author.MarshalJSON in the GitHub CLI), rather than the raw REST login github-actions[bot]. This predicate therefore rejects the Actions-created orphan after a successful issue creation followed by a failed link, so a rerun creates another child. Match the CLI's app/github-actions identity and update the recovery fixture in create-backport-issue.bats to use CLI-shaped author data.
Abort reconciliation when duplicate PR lookup fails
.github/scripts/extract-hotfix-versions.sh:105
cherry_pick_already_exists is called as an if condition, which disables Bash's errexit throughout the function. If gh pr list fails, existing_pr is empty and the helper reports no duplicate instead of stopping. Reconciliation can then recreate a closed backport PR whose branch was deleted. A focused shell check confirms this path proceeds with status zero. Explicitly abort on lookup failure; add an API-failure regression case and give the non-hotfix-label reconciliation test a successful lookup stub.
Recheck merge status after label sync and reconcile
.github/scripts/sync-hotfix-label-to-pr.sh:131
A PR can merge after the triggering PR snapshot (or the issue-side query reporting OPEN) but before this label addition. The merge event then has no Hotfix label, while this later GITHUB_TOKEN mutation cannot trigger another workflow run. The issue-side caller also skips dispatch because it uses the earlier OPEN state. Recheck merge status after syncing labels in this shared script and dispatch reconciliation if merged, so both entry points handle this ordering. Coordinate that dispatch with the issue-side caller and cover the merge-during-sync case.
Accept GitHub CLI's app-prefixed bot identity during orphan recovery
.github/scripts/create-backport-issue.sh:155
[P2] Accept the GitHub CLI's exported bot identity during orphan recovery. Its Author.MarshalJSON prefixes bot logins with app/, so this comparison against only github-actions[bot] rejects the Actions bot's issue. If creation succeeds but linking fails, a rerun misses that orphan and creates a duplicate. Accept the CLI-formatted identity and update the recovery test fixture to exercise that format rather than only the unprefixed login.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Merge-time label synchronization can lose backport requests, and failed PR lookups can bypass duplicate protection.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Abort when PR-existence lookup fails
.github/scripts/extract-hotfix-versions.sh:105
[P2] Abort when the PR-existence lookup fails. This helper is called as an if condition, which disables Bash's set -e handling throughout the function. A failed gh pr list therefore falls through to return 1 and schedules the version as if no backport existed; for a closed backport whose branch was deleted, this can create a duplicate. Explicitly exit on lookup failure rather than treating it as a successful empty result.
Recheck merged state after label synchronization
.github/scripts/sync-hotfix-label-to-pr.sh:132
[P2] Recheck merged state after synchronizing labels. If a PR merges before this mutation, its closed event can lack the Hotfix label, while adding the label afterward with GITHUB_TOKEN cannot trigger the cherry-pick workflow. This affects both PR-triggered runs and issue-triggered runs whose earlier GraphQL lookup recorded OPEN. Move merged-state reconciliation into this shared script after synchronization: query the current state and dispatch cherry-pick-hotfix.yml for merged PRs, including retries where the labels are already present, and cover the OPEN-to-MERGED ordering in tests.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A merge-time label synchronization race can miss cherry-picks, and failed PR lookups can bypass duplicate detection.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Abort on failed existing-PR lookup
.github/scripts/extract-hotfix-versions.sh:105
[P2] Abort when the existing-PR lookup fails. Calling this helper as an if condition disables Bash's errexit throughout the function. A failed gh pr list therefore leaves existing_pr empty and falls through to return 1, making the version eligible instead of stopping as the previous top-level assignment did. If an earlier cherry-pick PR still exists but its branch was deleted, an API failure can bypass the remaining duplicate guard. Explicitly exit on lookup failure and add a regression test for an absent branch followed by a failed PR lookup.
Reconcile merged PRs after label sync
.github/scripts/sync-hotfix-label-to-pr.sh:137
[P2] Recheck the live merge state after syncing labels. A queued PR-side sync can add the Hotfix label after the PR merges, so the merge event contains no Hotfix label. This GITHUB_TOKEN mutation cannot trigger the cherry-pick workflow's labeled event, leaving the backport unprocessed. The issue-side caller has the same gap when its earlier OPEN snapshot becomes stale. Dispatch reconciliation from this shared script when the post-sync state is MERGED, including when the label was already present on a retry. Add regression coverage for a merge between the initial lookup and label mutation; the issue-side caller's redundant dispatch can then be removed.
The reason will be displayed to describe this comment to others. Learn more.
I think the new Copilot findings are legitimate. But beware that you may be descending into a robot battle, and we may want to just merge to get 99% of the functionality without trying to achieve perfection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Extends the existing "Hotfix X.Y.Z" PR cherry-pick automation to also cover issues, so backport tracking issues are created and linked automatically instead of manually (as done for #4737/#4738).
create-backport-issue.sh+hotfix-label-issue.yml: labeling a parent issueHotfix X.Y.Zcreates a child backport issue milestoned to that version and links it as a native GitHub sub-issue. Includes duplicate detection (by milestone or title prefix) so a re-firedlabeledevent won't create a second backport issue.sync-hotfix-label-to-pr.sh+sync-hotfix-label-to-pr.yml: when a PR's closing issue references include a Hotfix-labeled issue, that label is copied onto the PR, feeding it into the existing cherry-pick automation.cherry-pick-to-release.sh(extended): looks up the milestone-matched backport issue via the original PR's closing references and appendsFixes #Nto the auto-generated cherry-pick PR body (both the clean and conflict paths), so merging the backport PR automatically closes the backport issue.issues: readpermission tocherry-pick-hotfix.ymlfor the new lookup.End-to-end flow: label an issue
Hotfix 7.1.1-> backport issue #N created and sub-issued -> PR opened closing the parent issue picks up theHotfix 7.1.1label -> merging that PR triggers the existing cherry-pick automation -> generated backport PR linksFixes #N.Issues
Not tied to a specific bug fix; this generalizes the manual backport-issue pattern used for #4737 and #4738 into automation.
Testing
Added bats coverage for all new/changed behavior, run locally with
bats-core:create-backport-issue.bats(10 tests): label validation, duplicate detection, milestone lookup, issue creation, sub-issue linking.sync-hotfix-label-to-pr.bats(7 tests): closing-reference parsing, label collection/dedup, idempotent sync.cherry-pick-to-release.bats(19 tests, 4 new): backport-issue lookup andFixes #Nlinking in both the clean and conflict PR-body paths; all 16 pre-existing tests still pass unmodified.Also ran
shellcheckagainst the new/modified scripts with no new findings.Guidelines
Please review the contribution guidelines before submitting a pull request: